#ifndef __DEBUG_API_H__
#define __DEBUG_API_H__

/* Log module type. */
typedef enum
{
    LOG_MODULE_BT = 0x00,
    LOG_MODULE_LWIP = 0x01,
    LOG_MODULE_LFS = 0x02,
    LOG_MODULE_SDK = 0x05,
    LOG_MODULE_MAX = 0xFF
} Log_Module_Type;

void UARTLogPrintf_Extend(unsigned char cat, const char *fmt, ...);
void UartLogPrintf(const char *fmt, ...);

#if defined(__LOG_UART__)
#define LOG_PRINTF(fmt, ...) UartLogPrintf(fmt, ##__VA_ARGS__)
#elif defined(__LOG_ACAT__)
#define LOG_PRINTF(fmt, ...) UARTLogPrintf_Extend(0x05, fmt, ##__VA_ARGS__)
#else
#define LOG_PRINTF(fmt, ...) do { } while (0)
#endif

void sdklogConfig(int type);
void sdkLogPrintf(const char *fmt, ...);

#define LOG_FI_L_PRINTF(fmt, ...) {\
    sdklogConfig(2); \
    sdkLogPrintf("%s:%d: ", __FILE__, __LINE__);\
    sdkLogPrintf(fmt, ##__VA_ARGS__);\
    sdkLogPrintf("\n");\
}

#define LOG_FU_L_PRINTF(fmt, ...) {\
    sdklogConfig(2); \
    sdkLogPrintf("%s:%d: ", __FUNCTION__, __LINE__);\
    sdkLogPrintf(fmt, ##__VA_ARGS__);\
    sdkLogPrintf("\n");\
}

#define LOG_L_PRINTF(fmt, ...) {\
    sdklogConfig(2); \
    sdkLogPrintf("%d: ", __LINE__);\
    sdkLogPrintf(fmt, ##__VA_ARGS__);\
    sdkLogPrintf("\n");\
}

void utilsAssertFail(const char *cond, const char *file, signed short line, unsigned char allowDiag);

#define WARNING(cOND) { if (!(cOND)) { utilsAssertFail(NULL, __FILE__, __LINE__, 0xFF); } }
#define ASSERT(cOND) { if (!(cOND)) { utilsAssertFail(#cOND, __FILE__, __LINE__, 1); } }
// #define WARNING(cOND)       do { } while(0)
// #define ASSERT(cOND)        do { } while(0)

void enable_uart_debug_info(void);

#endif /* __DEBUG_API_H__ */
